
<template>
  <div>
    <div style="overflow-x: hidden">
      <el-row :gutter="5">
        <el-col :span="8">
          <el-card class="mgb20" shadow="hover" style="height: 160px">
            <div class="user-info">
              <img alt class="user-avator" v-if="logininfo.photoimage != ''" :src="logininfo.photoimage" />
              <img alt class="user-avator" v-else-if="logininfo.sex == 2" src="@/assets/img/headwoman.jpg" />
              <img alt class="user-avator" v-else src="@/assets/img/headman.jpg" />
              <div class="user-info-cont">
                <div class="user-info-name">{{ name }}<a href="javascript:void(0)" style="font-size:20px"
                    @click="gopersonalhomepage"><i class="el-icon-document"></i></a></div>
                <div>
                  {{ logininfo.utype == "G" ? "超级管理员" : "普通用户" }}
                </div>
              </div>
              <div class="ilabic" v-if="!!Ops && !!Ops.ssoparam10" title="iLab标准化智慧实验室管理平台" @click="toilab">iLab</div>
            </div>
            <div class="user-info-list">
              <el-col :span="7">所属医院：</el-col>
              <el-col :span="17">
                <span>{{ logininfo.hospname }}</span>
              </el-col>
            </div>
            <div class="user-info-list">
              <el-col :span="7">所属检验组：</el-col>
              <el-col :span="17">
                <span>{{ logininfo.labgroupname }}</span>
              </el-col>
            </div>
          </el-card>
          <el-card shadow="hover" style="height: 200px">
            <div class="clearfix" slot="header">
              <span>系统消息</span>
              <el-button style="float: right; padding: 3px 0" type="text" @click="msgclick('', -1)">查看</el-button>
            </div>

            <el-table :data="msgList" :show-header="false" max-height="180" style="width: 100%; font-size: 14px"
              size="mini">
              <el-table-column>
                <template slot-scope="scope">
                  <div>
                    <div @click="msgclick(scope.row, 1)">
                      <el-row>
                        <el-col :span="2">
                          <el-button type="primary" round>{{ scope.row.id }}</el-button>
                        </el-col>
                        <el-col :span="17">{{ $pub.contrltextnum(scope.row.msg, 22) }}</el-col>
                        <el-col :span="5"><span style="font-size:10px;color:#909399">{{ scope.row.msgtime
                        }}</span></el-col>
                      </el-row>
                    </div>
                  </div>
                </template>
              </el-table-column>
              <!-- <el-table-column width="60">
                          <template slot-scope="scope">
                              <i @click="deletemsg(scope.row.id)" class="el-icon-delete"></i>
                          </template>
                      </el-table-column> -->
            </el-table>
          </el-card>
        </el-col>
        <el-col :span="16">
          <el-row :gutter="5" class="mgb20">
            <el-col :span="8">
              <el-card :body-style="{ padding: '0px' }" shadow="hover">
                <div class="grid-content grid-con-1">
                  <i class="el-icon-lx-people grid-con-icon"></i>
                  <div class="grid-cont-right">
                    <div class="grid-num">{{ cntdata.cnt1 }}</div>
                    <div>未上机/已接收标本数</div>
                  </div>
                </div>
              </el-card>
            </el-col>
            <el-col :span="8">
              <el-card :body-style="{ padding: '0px' }" shadow="hover">
                <div class="grid-content grid-con-2">
                  <i class="el-icon-lx-notice grid-con-icon"></i>
                  <div class="grid-cont-right">
                    <div class="grid-num">{{ cntdata.cnt2 }}</div>
                    <div>未审核/已核收报告数</div>
                  </div>
                </div>
              </el-card>
            </el-col>
            <el-col :span="8">
              <el-card :body-style="{ padding: '0px' }" shadow="hover">
                <div class="grid-content grid-con-3">
                  <i class="el-icon-lx-goods grid-con-icon"></i>
                  <div class="grid-cont-right">
                    <div class="grid-num">{{ cntdata.cnt3 }}</div>
                    <div>超时数/危急值数</div>
                  </div>
                </div>
              </el-card>
            </el-col>
          </el-row>
          <el-row :gutter="5">
            <el-col :span="12">
              <el-card shadow="hover" style="height: 293px">
                <div class="clearfix" slot="header">
                  <span>待办事项</span>
                  <!-- <el-button style="float: right; padding: 3px 0" type="text">添加</el-button> -->
                </div>
                <el-table :data="todoList" :show-header="false" height="290" style="width: 100%; font-size: 14px">
                  <el-table-column>
                    <template slot-scope="scope">
                      <div class="todo-item">{{ scope.row.msg }}</div>
                    </template>
                  </el-table-column>
                </el-table>
              </el-card>
            </el-col>
            <el-col :span="12">
              <el-card shadow="hover" style="height: 293px">
                <div class="clearfix" slot="header">
                  <span>我的常用程序</span>
                  <el-button style="float: right; padding: 3px 0" type="text" @click="CustomPanel">设置</el-button>
                </div>
                <el-table :data="prgList" :show-header="false" max-height="270" style="width: 100%; font-size: 14px"
                  size="mini" :key="prglstkey">
                  <el-table-column type="index" width="45" style="padding-left: 0px">
                  </el-table-column>
                  <el-table-column>
                    <template slot-scope="scope">
                      <div>
                        <div @click="jump(scope.row)" class="prg-item">
                          {{ scope.row.prgname }}
                        </div>
                        <div style="float: right">
                          <el-tooltip class="item" effect="dark" content="收藏置顶" placement="top-start" :open-delay="500">
                            <i v-show="scope.row.inuseflag != 1" class="el-icon-star-off" @click="PrgtoTop(scope.row)"
                              style="cursor: pointer; padding-right: 2px"></i>
                          </el-tooltip>
                          <el-tooltip class="item" effect="dark" content="取消收藏" placement="top-start" :open-delay="500">
                            <i v-show="scope.row.inuseflag == 1" class="el-icon-star-on" @click="cancelTop(scope.row)"
                              style="
                              cursor: pointer;
                              color: orange;
                              font-size: 18px;
                            "></i>
                          </el-tooltip>
                        </div>
                      </div>
                    </template>
                  </el-table-column>
                </el-table>
              </el-card>
            </el-col>
          </el-row>
        </el-col>
      </el-row>
      <el-row :gutter="5">
        <el-col :span="12">
          <el-card shadow="hover">
            <schart :data="data1" :options="options" canvasId="bar1" class="schart" ref="barrptcnt" type="bar"
              :style="{ height: schartHeight }"></schart>
          </el-card>
        </el-col>
        <el-col :span="12">
          <el-card shadow="hover">
            <schart :data="data2" :options="options2" canvasId="bar2" class="schart" ref="baramount" type="bar"
              :style="{ height: schartHeight }"></schart>
          </el-card>
        </el-col>
      </el-row>

      <el-dialog title="我的常用程序维护" :visible.sync="PanelVisible" v-el-drag-dialog :append-to-body="true"
        :close-on-click-modal="false">
        <el-dialog width="40%" title="排序" :visible.sync="innerVisible" append-to-body v-el-drag-dialog>
          <div>
            <vxe-table :data.sync="tableDate1" border style="width: 100%" height="300" :mouse-config="{ selected: true }"
              :edit-config="{
                trigger: 'click',
                mode: 'cell',
                showStatus: true,
              }" show-header-overflow="tooltip" show-overflow="tooltip" highlight-current-row highlight-hover-row
              resizable size="mini" ref="ddlCommonTableSort">
              <vxe-table-column field="sortcolumn" title="排序栏" width="200"
                :edit-render="{ name: 'select', options: getsortoptions }">
              </vxe-table-column>
              <vxe-table-column field="defaultsort" title="排序选择" show-overflow-tooltip width="200" align="center">
                <template v-slot="{ row }">
                  <el-radio v-model="row.defaultsort" label="1">升序</el-radio>
                  <el-radio v-model="row.defaultsort" label="2">降序</el-radio>
                </template>
              </vxe-table-column>
            </vxe-table>
          </div>
          <span slot="footer" class="dialog-footer">
            <el-button icon="el-icon-plus" @click="addsortrecord">新增</el-button>
            <el-button icon="el-icon-minus" @click="delsortrecord">删除</el-button>
            <el-button icon="el-icon-caret-top" @click="insertsortrecord">插入</el-button>
            <el-button icon="el-icon-delete" @click="tableDate1 = []">清除</el-button>
            <el-button icon="el-icon-circle-check" @click="savesortrecord">确定</el-button>
            <el-button icon="el-icon-circle-close" @click="innerVisible = false">退出</el-button>
          </span>
        </el-dialog>
        <div style="height: 500px; width: 100%; position: relative">
          <div class="pagetop">
            <table style="width: 100%" class="table1style">
              <tr>
                <td align="right">
                  <el-button @click="btnAdd">新增</el-button>
                  <el-button @click="btnInsert">插入</el-button>
                  <el-button @click="btnDelete">删除</el-button>
                  <el-button @click="btnSave">保存</el-button>
                  <el-button @click="btnRead">读取</el-button>
                  <el-button @click="innerVisible = true">排序</el-button>
                  <el-button @click="PanelVisible = false">取 消</el-button>
                </td>
              </tr>
            </table>
          </div>
          <div class="pagecenter">
            <div class="middle-center">
              <vxe-table show-overflow class="myclass" border ref="xTable" height="auto" size="mini" :loading="loading"
                :select-config="{ reserve: true }" :mouse-config="{ selected: true }" :data.sync="tableData"
                @cell-dblclick="CellDblclick" show-header-overflow highlight-current-row highlight-hover-row resizable
                stripe header-align="center" :edit-config="{
                  trigger: 'click',
                  mode: 'cell',
                  showStatus: true,
                  showIcon: false,
                }" :sort-config="{ trigger: 'cell' }">
                <vxe-table-column field="userno" title="用户代号" width="80"></vxe-table-column>
                <vxe-table-column field="prgno" title="程序代号(双击开窗)" width="135"
                  :edit-render="{ name: 'input', autoselect: true }" sortable></vxe-table-column>
                <vxe-table-column field="prgname" title="程序名称" width="170"
                  :edit-render="{ name: 'input', autoselect: true }" sortable>
                </vxe-table-column>
                <vxe-table-column field="inuseflag" title="常用" width="50" align="center" sortable>
                  <template v-slot="{ row }">
                    <el-checkbox true-label="1" false-label="0" v-model="row.inuseflag" size="mini"></el-checkbox>
                  </template>
                </vxe-table-column>
                <vxe-table-column field="seq" title="序号" width="55" :edit-render="{ name: 'input', autoselect: true }"
                  align="center" sortable></vxe-table-column>
                <vxe-table-column field="fontsize" title="字体大小" width="80"
                  :edit-render="{ name: 'input', autoselect: true }" sortable></vxe-table-column>
                <vxe-table-column field="fontcolorshow" title="字体颜色" width="80" align="center" sortable>
                  <template v-slot="{ row }">
                    <div style="height: 25px">
                      <el-color-picker v-model="row.fontcolorshow" @change="changeColorEvent(row)" size="mini"
                        style="width: 100%; height: 25px"></el-color-picker>
                    </div>
                  </template>
                </vxe-table-column>
              </vxe-table>
            </div>
          </div>
        </div>
      </el-dialog>
    </div>
    <el-dialog title="程序" :visible.sync="dialogVisible" width="30%" v-el-drag-dialog :close-on-click-modal="false">
      <div style="height: 400px; width: 100%; position: relative">
        <div class="pagetop">
          <table class="table1style">
            <tr>
              <td>
                <b font-weight="800">检 索</b>
              </td>
              <td>
                <el-input v-model="txtsearch" placeholder=""></el-input>
              </td>
              <td>
                <el-button type="primary" @click="dialogVisibleSure">确 定</el-button>
                <el-button @click="dialogVisible = false">取 消</el-button>
              </td>
            </tr>
          </table>
        </div>
        <div class="pagecenter">
          <div class="middle-center">
            <vxe-table show-overflow border ref="xTable2" height="auto" size="mini" :select-config="{ reserve: true }"
              :mouse-config="{ selected: true }" @cell-dblclick="getdialogdata" @current-change="currentChangeEvent"
              :data.sync="list" show-header-overflow highlight-current-row highlight-hover-row resizable stripe
              header-align="center" :edit-config="{
                trigger: 'click',
                mode: 'cell',
                showStatus: true,
                showIcon: false,
              }">
              <vxe-table-column field="prgcode" title="程序代号" width="130"></vxe-table-column>
              <vxe-table-column field="prgname" title="程序名称" width="230">
              </vxe-table-column>
            </vxe-table>
          </div>
        </div>
      </div>
    </el-dialog>
    <el-dialog title="医院" :visible.sync="HosdialogVisible" width="30%" v-el-drag-dialog :close-on-click-modal="false">
      <div style="height: 400px; width: 100%; position: relative">
        <div class="pagetop">
          <table class="table1style">
            <tr>
              <td>
                <b font-weight="800">检 索</b>
              </td>
              <td>
                <el-input v-model="hostxtsearch" placeholder=""></el-input>
              </td>
              <td>
                <el-button type="primary" @click="hosdialogVisibleSure">确 定</el-button>
                <el-button @click="hosdialogVisible = false">取 消</el-button>
              </td>
            </tr>
          </table>
        </div>
        <div class="pagecenter">
          <div class="middle-center">
            <vxe-table show-overflow border ref="xTable3" height="auto" size="mini" :mouse-config="{ selected: true }"
              :select-config="{ reserve: true }" @cell-click="gethosdata" :data.sync="hoslist" show-header-overflow
              highlight-current-row highlight-hover-row resizable stripe header-align="center"
              @select-change="SelectChange" @select-all="SelectAll">
              <vxe-table-column type="selection" width="60" align="center"></vxe-table-column>
              <vxe-table-column field="hospitalname" title="医院名称" width="130"></vxe-table-column>
            </vxe-table>
          </div>
        </div>
      </div>
    </el-dialog>
    <el-dialog title="图标" :visible.sync="icondialogVisible" width="30%" v-el-drag-dialog :close-on-click-modal="false">
      <div style="height: 400px; width: 100%; position: relative">
        <div class="pagecenter">
          <table style="height: 100%; width: 100%">
            <tr v-for="(titem, tindex) in IconList" :key="tindex">
              <td v-for="(sitems, sindex) in titem" :key="sindex">
                <span @click="geticondata(sitems)" style="font-size: 32px; margin: 15px"><i :class="sitems"></i></span>
              </td>
            </tr>
          </table>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import Schart from "vue-schart";
import XE from "xe-utils";
export default {
  data() {
    return {
      name: this.$tool.getSession(this.$tool.loginusername),
      logininfo: [],
      msgList: [],
      todoList: [],
      prgList: [],
      data1: [],
      data2: [],
      cntdata: [],
      txtprgno: "",
      txtprgname: "",
      txtseq: "",
      txtfontsize: "",
      txtsearch: "",
      hostxtsearch: "",
      PrgnoOption: [],
      Ops: {},
      IconList: [],
      nArray: [],
      tableData: [],
      tableDate1: [],
      tableData2: [],
      HospitaltableData: [],
      HostableData: [],
      HostableDate1: [],
      TempRow: [],
      CopyHosList: [],
      sortstr: "",
      schartHeight: "245px",
      getsortoptions: [
        { label: "", value: "" },
        { label: "程序代号", value: "prgno" },
        { label: "程序名称", value: "prgname" },
        { label: "序号", value: "seq" },
        { label: "用户代号", value: "userno" },
        { label: "字体大小", value: "fontsize" },
        { label: "字体颜色", value: "fontcolor" },
      ],
      loading: false,
      Hosloading: false,
      dialogVisible: false,
      icondialogVisible: false,
      HosdialogVisible: false,
      innerVisible: false,
      isconfig: false,
      HosinnerVisible: false,
      PanelVisible: false,
      HosPanelVisible: false,
      okFirstLoading: false,
      HosokFirstLoading: false,
      options: {
        title: "最近报告数",
        showValue: false,
        fillColor: "rgb(45, 140, 240)",
        bottomPadding: 30,
        topPadding: 30,
      },
      options2: {
        title: "最近收费金额",
        showValue: false,
        fillColor: "rgb(45, 140, 240)",
        bottomPadding: 30,
        topPadding: 30,
      },
      prglstkey: 0, //用于刷新el-table
      lis310multiple: "0",
    };
  },
  components: {
    Schart,
  },
  computed: {
    list() {
      let filterName = this.txtsearch.trim();
      if (filterName) {
        let filterRE = new RegExp(filterName, "gi");
        let rest = this.tableData2.filter((item) => {
          return item.prgcode.toUpperCase().indexOf(filterName.toUpperCase()) > -1 || (item.prgname ? item.prgname.indexOf(filterName) > -1 : false);
        });
        return rest;
      } else {
        return this.tableData2;
      }
    },
    hoslist() {
      let filterName = this.hostxtsearch.trim();
      if (filterName) {
        let filterRE = new RegExp(filterName, "gi");
        let rest = this.HospitaltableData.filter((item) => {
          return item.inputcode.toUpperCase().indexOf(filterName.toUpperCase()) > -1 || (item.hospitalname ? item.hospitalname.indexOf(filterName) > -1 : false);
        });
        return rest;
      } else {
        return this.HospitaltableData;
      }
    },
  },
  created() {
    this.lis310multiple = this.$tool.getLocalConfig("lis310multiple");
    // this.gettype();
    this.getOption();
    this.handleListener();
    // this.changeDate();
    this.getpagedata();
    this.getHeight();
    this.getPrgList();
    this.getIcon();
  },
  activated() {
    this.handleListener();
  },
  deactivated() {
    window.removeEventListener("resize", this.renderChart);
    this.$bus.$off("collapse", this.handleBus);
  },
  updated() {
    if (this.okFirstLoading) {
      this.$nextTick(() => {
        if (this.$refs.xTable) {
          let currentrow = this.$refs.xTable.getData(0);
          if (currentrow) {
            this.okFirstLoading = false;
            this.$refs.xTable.setCurrentRow(currentrow);
          }
        }
      });
    }
  },
  methods: {
    getHeight() {
      this.schartHeight = window.innerHeight - 450 + "px";
    },
    jump(prginfo) {
      this.$tool.setSession("currentmenu", prginfo.prgname);
      let path = prginfo.prgno;
      if (this.lis310multiple > 0) {
        if (path.indexOf("LIS310") > -1 || path.indexOf("LIS311") > -1) {
          path = this.$pub.getlis310path(this, path);
        }
      }
      this.$router.push("/" + path);
    },
    getpagedata() {
      this.getdatacomm("todolst");
      this.getdatacomm("message");
      this.getdatacomm("logininfo");
      this.getdatacomm("prglst");
      //this.getdatacomm("getcntdata");
      this.getimgdata();
    },
    getdatacomm(actionname) {
      let selhis = this.$tool.getSession(this.$tool.selectedhis);
      // localStorage.setItem("rmrptunititem", object);
      this.$tool
        .request({
          url: "/ucent/dashboard",
          method: "post",
          data: {
            action: actionname,
            his: selhis,
          },
        })
        .then((res) => {
          if (res.errcode == "1") {
            if (actionname == "todolst") {
              this.todoList = res.data;
              this.cntdata = res.cntdata;
            } else if (actionname == "message") {
              this.msgList = res.data;
              //每隔5分钟刷新一次首页消息
              setTimeout(() => {
                this.getdatacomm("message");
              }, 300000);
            } else if (actionname == "logininfo") {
              this.logininfo = res.data;
            } else if (actionname == "prglst") {
              // this.btnRead();
              this.prgList = res.data;
              this.prglstkey++;
            }
            // else if (actionname == "getcntdata") {
            //     this.cntdata = res.data;
            // }
          }
        })
        .catch((e) => { });
    },
    getIcon() {
      this.$tool
        .request({
          url: "/ucent/dashboard",
          method: "post",
          data: {
            action: "getIcon",
          },
        })
        .then((res) => {
          if (res.errcode == "1") {
            if (res.data) this.IconList = res.data;
          }
        })
        .catch((e) => { });
    },
    getPrgList() {
      this.$tool
        .request({
          url: "/ucent/dashboard",
          method: "post",
          data: {
            action: "getPrgList",
          },
        })
        .then((res) => {
          if (res.errcode == "1") {
            if (res.data) {
              this.nArray = res.data;
            }
          }
        })
        .catch((e) => { });
    },
    getimgdata() {
      this.$tool
        .request({
          url: "/ucent/dashboard",
          method: "post",
          data: {
            action: "imgdata",
          },
        })
        .then((res) => {
          if (res.errcode == "1") {
            if (res.data1) this.data1 = res.data1;
            if (res.data2) this.data2 = res.data2;
          }
        })
        .catch((e) => { });
    },
    // changeDate() {
    //     const now = new Date().getTime();
    //     this.data.forEach((item, index) => {
    //         const date = new Date(now - (6 - index) * 86400000);
    //         item.name = `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`;
    //     });
    // },
    getOption() {
      this.$tool
        .request({
          url: "/ucent/dashboard",
          method: "post",
          data: {
            action: "getOption",
          },
        })
        .then((res) => {
          this.tableData2 = res.data;
          this.PrgnoOption.push({ prgcode: "", prgname: "" });
          res.data.forEach((item) => {
            this.PrgnoOption.push(item);
          });
          this.Ops = res.ops;
        })
        .catch((e) => {
          console.log("error", e);
        });
    },
    CellDblclick({ row }) {
      this.dialogVisible = true;
      this.TempRow = row;
    },
    currentChangeEvent({ row }) {
      this.prgcode = row.prgcode;
      this.prgname = row.prgname;
    },
    getdialogdata() {
      var seq = 0;
      var ishave = false;
      var datarecord = this.$refs.xTable.tableData;
      if (datarecord.length > 0) {
        try {
          datarecord.forEach((item) => {
            if (item.prgno == this.prgcode) {
              ishave = true;
              throw Error();
            } else {
              ishave = false;
            }
            if (Number(item.seq) / 10 > seq) {
              seq = Number(item.seq) / 10;
            }
          });
        } catch (e) { }
      }
      if (ishave) {
        this.$message.warning("所选程序重复！");
        return false;
      }
      this.dialogVisible = false;
      seq++;
      this.TempRow.seq = seq * 10;
      this.TempRow.prgno = this.prgcode;
      this.TempRow.prgname = this.prgname;
    },
    dialogVisibleSure() {
      this.getdialogdata();
    },
    geticondata(val) {
      this.TempRow.icon = val;
      this.icondialogVisible = false;
    },
    iconClikc({ row, column }) {
      if (column.property == "icon") this.icondialogVisible = true;
      this.TempRow = row;
    },
    CustomPanel() {
      this.PanelVisible = true;
      this.btnRead();
    },
    HosPanel() {
      this.HosPanelVisible = true;
      this.HosbtnRead();
    },
    PrgtoTop(row) {
      var that = this;
      row.inuseflag = 1;
      row.usedt = new Date();
      that.updateSort(row);
    },
    cancelTop(row) {
      var that = this;
      row.inuseflag = 0;
      row.usedt = "";
      that.updateSort(row);
    },
    updateSort(row) {
      // console.log("update:" + JSON.stringify(row));
      this.$tool
        .request({
          url: "/ucent/dashboard",
          method: "post",
          data: {
            action: "UpdateSort",
            updatedata: row,
          },
        })
        .then((res) => {
          if (res.errcode == "1") {
            // this.$message.success("保存成功！");//  剔除保存提示
            //保存成功 常用程序列表也需要刷新
            this.getdatacomm("prglst");
            this.getPrgList();
          } else {
            // 错误消息窗口添加[showClose:true] 可关闭
            this.$message({
              showClose: true,
              message: "保存失败！" + res.Data.Item2,
              type: "warning",
            });
          }
        })
        .catch((e) => {
          console.log("error", e);
        });
    },
    //程序维护保存
    btnSave() {
      return new Promise((s, f) => {
        let oritable = this.$refs.xTable.tableData;
        for (let i = 0, len = oritable.length; i < len; i++) {
          oritable[i].seq = (i + 1) * 10;
        }
        let xTabledate = this.$refs.xTable.getRecordset();
        // if (xTabledate.insertRecords.length > 0) {
        //     for (let i = 0; i < xTabledate.insertRecords.length; i++) {
        //         xTabledate.insertRecords[i].inuseflag = xTabledate.insertRecords[i].inuseflag ? "1" : "0";
        //         xTabledate.insertRecords[i].fontcolor = xTabledate.insertRecords[i].fontcolor ? xTabledate.insertRecords[i].fontcolor : null;
        //         xTabledate.insertRecords[i].fontsize = xTabledate.insertRecords[i].fontsize ? xTabledate.insertRecords[i].fontsize : "12";
        //     }
        // }
        // if (xTabledate.removeRecords.length > 0) {
        //     for (let i = 0; i < xTabledate.removeRecords.length; i++) {
        //         xTabledate.removeRecords[i].inuseflag = xTabledate.removeRecords[i].inuseflag ? "1" : "0";
        //         xTabledate.removeRecords[i].fontcolor = xTabledate.removeRecords[i].fontcolor ? xTabledate.removeRecords[i].fontcolor : null;
        //         xTabledate.removeRecords[i].fontsize = xTabledate.removeRecords[i].fontsize ? xTabledate.removeRecords[i].fontsize : "12";
        //     }
        // }
        // if (xTabledate.updateRecords.length > 0) {
        //     for (let i = 0; i < xTabledate.updateRecords.length; i++) {
        //         xTabledate.updateRecords[i].odata.inuseflag = xTabledate.updateRecords[i].odata.inuseflag ? "1" : "0";
        //         xTabledate.updateRecords[i].odata.fontcolor = xTabledate.updateRecords[i].odata.fontcolor ? xTabledate.updateRecords[i].odata.fontcolor : null;
        //         xTabledate.updateRecords[i].odata.fontsize = xTabledate.updateRecords[i].odata.fontsize ? xTabledate.updateRecords[i].odata.fontsize : "12";
        //         xTabledate.updateRecords[i].cdata.inuseflag = xTabledate.updateRecords[i].cdata.inuseflag ? "1" : "0";
        //         xTabledate.updateRecords[i].cdata.fontcolor = xTabledate.updateRecords[i].cdata.fontcolor ? xTabledate.updateRecords[i].cdata.fontcolor : null;
        //         xTabledate.updateRecords[i].cdata.fontsize = xTabledate.updateRecords[i].cdata.fontsize ? xTabledate.updateRecords[i].cdata.fontsize : "12";
        //     }
        // }
        this.$tool
          .request({
            url: "/ucent/dashboard",
            method: "post",
            data: {
              action: "savedata",
              saveinfo: xTabledate,
            },
          })
          .then((res) => {
            if (res.errcode == "1") {
              this.$message.success("保存成功！");
              this.btnRead();
              this.getdatacomm("prglst"); //同步刷新prglst
              s();
            } else {
              this.$message.error("保存失败！" + res.errmsg);
              f();
            }
          })
          .catch((e) => {
            console.log("error", e);
            f();
          });
      });
    },
    //程序维护保存
    HosbtnSave() {
      return new Promise((s, f) => {
        let oritable = this.$refs.HosxTable.tableData;
        for (let i = 0, len = oritable.length; i < len; i++) {
          oritable[i].seq = (i + 1) * 10;
        }
        let xTabledate = this.$refs.HosxTable.getRecordset();
        this.$tool
          .request({
            url: "/ucent/dashboard",
            method: "post",
            data: {
              action: "Hossavedata",
              saveinfo: xTabledate,
            },
          })
          .then((res) => {
            if (res.errcode == "1") {
              this.$message.success("保存成功！");
              this.HosbtnRead();
              this.getdatacomm("prglst"); //同步刷新prglst
              this.getPrgList();
              s();
            } else {
              this.$message.error("保存失败！" + res.errmsg);
              f();
            }
          })
          .catch((e) => {
            console.log("error", e);
            f();
          });
      });
    },
    //程序维护新增
    btnAdd() {
      this.$refs.xTable
        .insert({
          userno: "",
          prgcode: "",
          prgname: "",
          seq: "",
          fontsize: "",
          fontcolor: "000000",
        })
        .then(({ row }) => {
          this.$nextTick(() => {
            this.$refs.xTable.setCurrentRow(row);
            this.$refs.xTable.setActiveRow(row, "prgcode");
          });
        });
    },
    //程序维护新增
    HosbtnAdd() {
      this.$refs.HosxTable.insert({
        userno: "",
        prgcode: "",
        prgname: "",
        seq: "",
        fontsize: "",
        fontcolor: "000000",
      }).then(({ row }) => {
        this.$nextTick(() => {
          this.$refs.HosxTable.setCurrentRow(row);
          this.$refs.HosxTable.setActiveRow(row, "prgcode");
        });
      });
    },
    //程序维护插入
    btnInsert() {
      var data = this.$refs.xTable.tableData;
      if (data.length > 0) {
        var crow = this.$refs.xTable.getCurrentRow();
        if (crow) {
          this.$refs.xTable
            .insertAt(
              {
                userno: "",
                prgcode: "",
                prgname: "",
                seq: "",
                fontsize: "",
                fontcolor: "000000",
              },
              crow
            )
            .then(({ row }) => {
              this.$nextTick(() => {
                this.$refs.xTable.setCurrentRow(row);
                this.$refs.xTable.setActiveRow(row, "prgcode");
              });
            });
        } else {
          this.btnAdd();
        }
      } else {
        this.btnAdd();
      }
    },
    //程序维护插入
    HosbtnInsert() {
      var data = this.$refs.HosxTable.tableData;
      if (data.length > 0) {
        var crow = this.$refs.HosxTable.getCurrentRow();
        if (crow) {
          this.$refs.HosxTable.insertAt(
            {
              userno: "",
              prgcode: "",
              prgname: "",
              seq: "",
              fontsize: "",
              fontcolor: "000000",
            },
            crow
          ).then(({ row }) => {
            this.$nextTick(() => {
              this.$refs.HosxTable.setCurrentRow(row);
              this.$refs.HosxTable.setActiveRow(row, "prgcode");
            });
          });
        } else {
          this.HosbtnAdd();
        }
      } else {
        this.HosbtnAdd();
      }
    },
    //程序维护删除
    btnDelete() {
      try {
        var delrow = this.$refs.xTable.getCurrentRow();
        if (delrow) {
          var alld = this.$refs.xTable.tableData;
          var rowindex = alld.indexOf(delrow);
          this.$refs.xTable.remove(delrow);
          let havedata = this.$refs.xTable.tableData;
          if (havedata.length > 0) {
            if (rowindex >= havedata.length) rowindex = havedata.length - 1;
            let selectrow = havedata[rowindex];
            this.$refs.xTable.setCurrentRow(selectrow);
          }
        }
      } catch (e) {
        console.log("error", e);
      }
    },
    //程序维护删除
    HosbtnDelete() {
      try {
        var delrow = this.$refs.HosxTable.getCurrentRow();
        if (delrow) {
          var alld = this.$refs.HosxTable.tableData;
          var rowindex = alld.indexOf(delrow);
          this.$refs.HosxTable.remove(delrow);
          let havedata = this.$refs.HosxTable.tableData;
          if (havedata.length > 0) {
            if (rowindex >= havedata.length) rowindex = havedata.length - 1;
            let selectrow = havedata[rowindex];
            this.$refs.HosxTable.setCurrentRow(selectrow);
          }
        }
      } catch (e) {
        console.log("error", e);
      }
    },
    //程序维护读取
    btnRead() {
      this.loading = true;
      this.$tool
        .request({
          url: "/ucent/dashboard",
          method: "post",
          data: {
            action: "Readdata",
            sortstr: "",
          },
        })
        .then((res) => {
          var datas = res.data;
          // for (let i = 0; i < datas.length; i++) {
          // datas[i].inuseflag = XE.toString(datas[i].inuseflag);

          //     datas[i].inuseflag = datas[i].inuseflag == "1" ? true : false;
          //     datas[i].fontcolor = datas[i].fontcolor + "";
          // }
          datas.forEach((e) => {
            e.inuseflag = XE.toString(e.inuseflag);
            e.fontcolorshow = this.$pub.ColorChange(e.fontcolor); //转为带#的颜色
          });
          this.tableData = datas;
          this.okFirstLoading = true;
          this.loading = false;
        })
        .catch((e) => {
          console.log("error", e);
          this.loading = false;
        });
    },
    HosbtnRead() {
      this.Hosloading = true;
      this.$tool
        .request({
          url: "/ucent/dashboard",
          method: "post",
          data: {
            action: "ReadHosdata",
            sortstr: "",
          },
        })
        .then((res) => {
          var datas = res.data;
          this.HostableData = datas;
          this.HosokFirstLoading = true;
          this.Hosloading = false;
        })
        .catch((e) => {
          console.log("error", e);
          this.Hosloading = false;
        });
    },
    CopyHosPanel() {
      this.$tool
        .request({
          url: "/ucent/dashboard",
          method: "post",
          data: {
            action: "HospitaltableData",
          },
        })
        .then((res) => {
          var datas = res.data;
          this.HospitaltableData = datas;
          this.HosdialogVisible = true;
        })
        .catch((e) => {
          console.log("error", e);
          this.HosdialogVisible = false;
        });
    },
    hosdialogVisibleSure() {
      if (this.CopyHosList.length > 0) {
        this.$confirm(`您确定要覆盖其他医院配置吗？`, {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.$tool
              .request({
                url: "/ucent/dashboard",
                method: "post",
                data: {
                  action: "HospitaltableDataUpd",
                  data: this.CopyHosList,
                },
              })
              .then((res) => {
                if (res.errcode == "1") {
                  this.$pub.message(this, "保存成功！", "success");
                  this.GetFiles(this.fileclassid);
                } else {
                  this.$message({ message: res.obj, type: "error" });
                }
              })
              .catch((e) => {
                console.log("error", e);
                this.HosdialogVisible = false;
              });
          })
          .catch((e) => { });
      } else {
        this.$message({ message: "请选择医院！", type: "warning" });
      }
    },
    //排序新增
    addsortrecord() {
      if (this.type == 0) {
        this.$refs.ddlCommonTableSort.insert({
          sortcolumn: "",
          defaultsort: "1",
        });
      } else {
        this.$refs.HosddlCommonTableSort.insert({
          sortcolumn: "",
          defaultsort: "1",
        });
      }
    },
    //排序删除
    delsortrecord() {
      var delrow = this.$refs.ddlCommonTableSort.getCurrentRow();
      if (delrow) {
        this.$refs.ddlCommonTableSort.remove(delrow);
      } else {
        this.$message({
          message: "请先选中要删除的排序！",
          type: "warning",
        });
      }
    },
    //排序插入
    insertsortrecord() {
      var crow = this.$refs.ddlCommonTableSort.getCurrentRow();
      if (crow) {
        this.$refs.ddlCommonTableSort.insertAt({ sortcolumn: "", defaultsort: "1" }, crow);
      } else {
        this.$refs.ddlCommonTableSort.insert({
          sortcolumn: "",
          defaultsort: "1",
        });
      }
    },
    //排序保存
    savesortrecord() {
      this.innerVisible = false;
      let sortstr = this.$refs.ddlCommonTableSort.tableData;
      this.loading = true;
      this.$tool
        .request({
          url: "/ucent/dashboard",
          method: "post",
          data: {
            action: "Readdata",
            sortstr: sortstr,
          },
        })
        .then((res) => {
          this.tableData = res.data;
          this.okFirstLoading = true;
          this.loading = false;
        })
        .catch((e) => {
          console.log("error", e);
          this.loading = false;
        });
    },
    handleListener() {
      this.$bus.$on("collapse", this.handleBus);
      // 调用renderChart方法对图表进行重新渲染
      window.addEventListener("resize", this.renderChart);
    },
    handleBus(msg) {
      let temptimeout1 = setTimeout(() => {
        this.renderChart();
        clearTimeout(temptimeout1);
      }, 300);
    },
    renderChart() {
      this.$refs.barrptcnt.renderChart();
      this.$refs.baramount.renderChart();
    },
    //保存颜色
    //设置->保存报错[Convert string to decimal]修改
    changeColorEvent(row) {
      let color = row.fontcolorshow.split("#")[1];
      if (!!color) {
        row.fontcolor = this.$pub.ColorTrans(color);
      }
    },

    SelectChange(selection) {
      this.CopyHosList = selection.selection;
    },
    SelectAll(selection) {
      this.CopyHosList = selection.selection;
      console.log(this.CopyHosList);
    },
    gethosdata({ row }) {
      this.$refs.xTable3.toggleRowSelection(row);
      this.CopyHosList = this.$refs.xTable3.getSelectRecords();
    },
    toilab() {
      if (this.Ops && this.Ops.ssoparam10) {
        var t = this.$tool.getSession(this.$tool.logintoken);
        var url = this.Ops.ssoparam10 + "?token=" + t;
        if (typeof jsObj != "undefined") {
          jsObj.SetWindowStyle(true, true, false);
          window.open(url);
        } else {
          window.open(url);
        }
      }
    },
    gopersonalhomepage() {
      this.$router.push({ path: "/personalhomepage", query: { p1: this.$tool.getSession(this.$tool.loginuserno) } });
    },
    //消息点击进入消息中心页面
    msgclick(msgitem, index) {
      // console.log(msgitem);
      if (index > 0) {
        this.$router.push({ path: "/msgcenter_page", query: msgitem.paramlist });
      } else {
        //消息全部被已读时，点击系统消息进入消息中心
        this.$router.push({ path: "/msgcenter_page", query: { p1: "16", p2: "", p3: this.$tool.getSession(this.$tool.loginuserno) } });
      }
    },
  },
  beforeDestroy() {
    this.$bus.$off("collapse");
    window.removeEventListener("resize", this.renderChart);
  },
};
</script>


<style scoped>
.user-info-name {
  margin-right: 15px;
  font-size: 14px;
  /* font-style: italic; */
  font-weight: bold;
  /* text-decoration: underline; */
  /* cursor: pointer; */
}

.el-row {
  margin-bottom: 2.5px;
}

.grid-content {
  display: flex;
  align-items: center;
  height: 65px;
}

.grid-cont-right {
  flex: 1;
  text-align: center;
  font-size: 14px;
  color: #999;
}

.grid-num {
  font-size: 30px;
  font-weight: bold;
}

.grid-con-icon {
  font-size: 50px;
  width: 100px;
  height: 100px;
  text-align: center;
  line-height: 100px;
  color: #fff;
}

.grid-con-1 .grid-con-icon {
  background: rgb(45, 140, 240);
}

.grid-con-1 .grid-num {
  color: rgb(45, 140, 240);
}

.grid-con-2 .grid-con-icon {
  background: rgb(100, 213, 114);
}

.grid-con-2 .grid-num {
  color: rgb(45, 140, 240);
}

.grid-con-3 .grid-con-icon {
  background: rgb(242, 94, 67);
}

.grid-con-3 .grid-num {
  color: rgb(242, 94, 67);
}

.user-info {
  display: flex;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 2px solid #ccc;
  margin-bottom: 5px;
}

.user-avator {
  width: 80px;
  height: 80px;
  border-radius: 50%;
}

.user-info-cont {
  padding-left: 50px;
  flex: 1;
  font-size: 14px;
  color: #999;
}

.user-info-cont div:first-child {
  font-size: 30px;
  color: #222;
}

.user-info-list {
  font-size: 14px;
  color: #999;
  line-height: 25px;
}

/* .user-info-list span {
  margin-left: 70px;
} */

.mgb20 {
  margin-bottom: 5px;
}

.prg-item {
  font-size: 14px;
  color: blue;
  cursor: pointer;
  float: left;
}

.msg-item {
  font-size: 14px;
  width: 100%;
}

.todo-item {
  font-size: 14px;
}

.todo-item-del {
  text-decoration: line-through;
  color: #999;
}

.schart {
  width: 100%;
  /* height: 245px;*/
}

.pagetop {
  width: 100%;
  height: 35px;
  display: -webkit-box;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  border: 1px solid #ccc;
  position: absolute;
  z-index: 99;
}

.pagetop2 {
  width: 100%;
  height: 35px;
  display: -webkit-box;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  border: 1px solid #ccc;
  position: absolute;
  font-size: 12px;
  z-index: 99;
  overflow-x: auto;
  white-space: nowrap;
}

.pagetop2 .top-table {
  float: right;
}

.top-button {
  right: 5px;
  position: absolute;
  top: 5px;
  display: flex;
  align-items: center;
}

.pagecenter {
  position: absolute;
  top: 40px;
  width: 100%;
  left: 0;
  right: 0px;
  bottom: 0px;
  overflow: auto;
}

.middle-center {
  position: absolute;
  height: 100%;
  width: 100%;
  left: 0px;
  right: 0px;
  overflow: auto;
}

.pagebottom {
  position: absolute;
  -webkit-box-pack: center;
  -webkit-box-align: bottom;
  bottom: 0px;
  width: 100%;
  height: 40px;
  right: 0px;
  border: 1px solid #ccc;
}

.table1style tr td {
  padding: 3px 2px 3px 5px;
}

.myclass .el-color-picker--mini .el-color-picker__trigger {
  width: 90px;
}

.myclass .el-color-picker__trigger {
  padding: 0px;
}

.el-card__header {
  padding: 10px 12px !important;
}

.el-card__body {
  padding: 0px 10px 0px 10px !important;
}

.el-table--small td,
.el-table--small th {
  padding: 3px 0;
}

.pagecenter2 {
  position: absolute;
  top: 75px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
  border: 1px solid #ccc;
}

.scroll_title {
  padding: 0px 0px 0px 0px;
  color: #333333;
  background-color: #d6d9da;
  font-size: 14px;
  font-weight: bold;
}

.scroll_content {
  line-height: 30px;
  color: #5e6267;
  font-size: 15px;
  text-decoration: none;
  -webkit-transition: color 0.3s;
  transition: color 0.3s;
  padding-left: 50px;
}

.ilabic {
  color: blue;
  font-size: 20px;
  font-style: italic;
  font-weight: bold;
  text-decoration: underline;
  cursor: pointer;
}
</style>
